package zero.tech.games.phz.process;

import com.alibaba.fastjson.JSONObject;

import zero.tech.core.ZeroContext;
import zero.tech.core.data.Resp;
import zero.tech.games.logic.common.Room;
import zero.tech.games.logic.process.ReqRoomProcess;
import zero.tech.games.phz.data.consts.CphOp;
import zero.tech.games.phz.data.consts.PHZCMD;
import zero.tech.games.phz.data.req.ReqChipai;
import zero.tech.games.phz.data.req.ReqGuopai;
import zero.tech.games.phz.data.req.ReqHupai;
import zero.tech.games.phz.data.req.ReqPengpai;
import zero.tech.games.phz.service.api.IPhzService;
import zero.tech.wsnet.controller.LogicController;
import zero.tech.wsnet.data.IREQ;
@IREQ(code = PHZCMD.REQ_CPHOP)
public class ReqCphOp extends ReqRoomProcess{

	@Override
	public void process(Room room, LogicController controller, Resp param) {
		IPhzService  phzService = ZeroContext.getInstance(IPhzService.class);
		JSONObject obj = (JSONObject) param.getParam();
		int op=obj.getIntValue("op");
		if(op==CphOp.HU) {
			ReqHupai reqHupai = JSONObject.parseObject(obj.toJSONString(), ReqHupai.class);
			reqHupai.setUid(controller.getId());
			phzService.reqHupai(room,controller,reqHupai,op);
		}else if(op==CphOp.PENGPAI) {
			ReqPengpai reqPengpai = JSONObject.parseObject(obj.toJSONString(), ReqPengpai.class);
			reqPengpai.setUid(controller.getId());
			phzService.reqPengpai(room,controller,reqPengpai,op);
		}else if(op==CphOp.CHIPAI) {
			ReqChipai reqChipai = JSONObject.parseObject(obj.toJSONString(), ReqChipai.class);
			reqChipai.setUid(controller.getId());
			phzService.reqChipai(room,controller,reqChipai,op);
		}else if(op==CphOp.PASS) {
			ReqGuopai reqGuopai = JSONObject.parseObject(obj.toJSONString(), ReqGuopai.class);
			reqGuopai.setUid(controller.getId());
			phzService.reqGuopai(room,controller,reqGuopai,op);
		}
	}

}
